﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Odds.Entity;
using Odds.DBUtility;
using System.Data;
using System.Data.Linq;

namespace Odds.DataAccess
{
    public class OddsValueController
    {
        public bool Insert(List<OddsValue> oddsValueSet)
        {
            bool result = false;
            try
            {
                StringBuilder sql = new StringBuilder();
                foreach (OddsValue oddsValue in oddsValueSet)
                {
                    Guid guid = Guid.NewGuid();
                    sql.AppendFormat("EXEC Pro_OddsValueInsert '{0}','{1}',{2},'{3}','{4}',{5},{6},{7};" + Environment.NewLine,
                                        guid, oddsValue.IssueItemID, oddsValue.IndexInIssueItem, oddsValue.CompanyID,
                                        oddsValue.OddsDatetime, oddsValue.OddsWin, oddsValue.OddsDraw, oddsValue.OddsLose);
                }
                OddsSQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString());
                result = true;
            }
            catch (Exception e)
            {
                throw e;
            }
            return result;
        }

        public IQueryable<Fun_GetOddsIssueItemoOddsValueByIssueIDResult> GetOddsIssueItemoOddsValueByIssue(Guid issueID)
        {
            return new OddsRecorderContextWrapper().Fun_GetOddsIssueItemoOddsValueByIssueID(issueID);            
        }
    }
}
